const base = require("./base");
const app = getApp();

const template = {
  getAllTemplates(callback) {
    base.get('incidentTemplates/' + app.globalData.currentOrg, callback,{
      skipPaging: true
    })
  },
  getTemplate(templateId, callback){
    base.get(`incidentTemplates/${app.globalData.currentOrg}/${templateId}`, callback)
  },
  getVariables(templateId, callback, phase="New") {
    base.get(`incidentVariableItems/${app.globalData.currentOrg}/${templateId}/${phase}`, callback)
  },
  launch(template,callback){
    base.post(`incidents/${app.globalData.currentOrg}`,callback, template)
  }
};

module.exports = template;
